/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __logic_gamestate_state_h
#define __logic_gamestate_state_h

#include <boost/enable_shared_from_this.hpp>

#include <Modules/Logic/Types.h>

namespace galaxy {
    namespace logic {
        namespace gamestate {

            /** 'Abstract' class that models a state in the game. A state can be 'mainmenu', 
            * 'exit' or 'settings'. The state can be setup, activated and terminated.
            * Each state is identified by a state-name and is implemented as specilization of this class
            */
            class State: public boost::enable_shared_from_this<State>
            {
            
            protected:
                /** manager access */
                ManagerPtr m_StateManager; 

            public:

                State();
                virtual ~State();

                /** Setup the game state. This method is intended to prepare the game state
                * @return true upon success and false upon failure
                */
                virtual bool setupState () { return true; };

                /** Activate the game state. This method is intended to notify other modules to actually
                * change to the game state
                * @return true upon success and false upon failure
                */
                virtual bool activateState () { return true; };

                /** Terminate the game state. This method is intended to destroy resources that are 
                * in use by this game state.
                * @return true upon success and false upon failure
                */
                virtual bool terminateState () { return true; };

                // FIXME: change this to return a logic::State::Name
                /** the state's name */
                virtual const char * stateName () = 0;

                ManagerPtr& getStateManager () { return m_StateManager; };
                void setStateManager (ManagerPtr& manager) { m_StateManager = manager; };
            };

        } // namespace gamestate
    } // namespace logic
} // namespace galaxy

#endif // __logic_gamestate_state_h
